package com.milling.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.milling.common.annotation.Log;
import com.milling.common.core.controller.BaseController;
import com.milling.common.core.domain.AjaxResult;
import com.milling.common.enums.BusinessType;
import com.milling.business.domain.WmsDrillinfoSetting;
import com.milling.business.service.IWmsDrillinfoSettingService;
import com.milling.common.utils.poi.ExcelUtil;
import com.milling.common.core.page.TableDataInfo;

/**
 * drillSettingController
 *
 * @author X
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/business/stocksetting")
public class WmsDrillinfoSettingController extends BaseController
{
    @Autowired
    private IWmsDrillinfoSettingService wmsDrillinfoSettingService;

    /**
     * 查询drillSetting列表
     */
    @PreAuthorize("@ss.hasPermi('business:stocksetting:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsDrillinfoSetting wmsDrillinfoSetting)
    {
        startPage();
        List<WmsDrillinfoSetting> list = wmsDrillinfoSettingService.selectWmsDrillinfoSettingList(wmsDrillinfoSetting);
        return getDataTable(list);
    }

    /**
     * 导出drillSetting列表
     */
    @PreAuthorize("@ss.hasPermi('business:stocksetting:export')")
    @Log(title = "drillSetting", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsDrillinfoSetting wmsDrillinfoSetting)
    {
        List<WmsDrillinfoSetting> list = wmsDrillinfoSettingService.selectWmsDrillinfoSettingList(wmsDrillinfoSetting);
        ExcelUtil<WmsDrillinfoSetting> util = new ExcelUtil<WmsDrillinfoSetting>(WmsDrillinfoSetting.class);
        util.exportExcel(response, list, "drillSetting数据");
    }

    /**
     * 获取drillSetting详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:stocksetting:query')")
    @GetMapping(value = "/{drillInfo}")
    public AjaxResult getInfo(@PathVariable("drillInfo") String drillInfo)
    {
        return success(wmsDrillinfoSettingService.selectWmsDrillinfoSettingByDrillInfo(drillInfo));
    }

    /**
     * 新增drillSetting
     */
    @PreAuthorize("@ss.hasPermi('business:stocksetting:add')")
    @Log(title = "drillSetting", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsDrillinfoSetting wmsDrillinfoSetting)
    {
        return toAjax(wmsDrillinfoSettingService.insertWmsDrillinfoSetting(wmsDrillinfoSetting));
    }

    /**
     * 修改drillSetting
     */
    @PreAuthorize("@ss.hasPermi('business:stocksetting:edit')")
    @Log(title = "drillSetting", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsDrillinfoSetting wmsDrillinfoSetting)
    {
        return toAjax(wmsDrillinfoSettingService.updateWmsDrillinfoSetting(wmsDrillinfoSetting));
    }

    /**
     * 删除drillSetting
     */
    @PreAuthorize("@ss.hasPermi('business:stocksetting:remove')")
    @Log(title = "drillSetting", businessType = BusinessType.DELETE)
    @DeleteMapping("/{drillInfos}")
    public AjaxResult remove(@PathVariable String[] drillInfos)
    {
        return toAjax(wmsDrillinfoSettingService.deleteWmsDrillinfoSettingByDrillInfos(drillInfos));
    }


    //    @PreAuthorize("@ss.hasPermi('business:stocksetting:remove')")
    @Log(title = "drillSetting", businessType = BusinessType.OTHER)
    @PostMapping("/feedingCache")
    public AjaxResult feedingCache(@RequestBody String jsonString)
    {
        //判断D600状态，写入D600
        //启动缓存库补料线程
        return AjaxResult.success("ok");
    }

}
